from django.db import models
from datetime import datetime

# Create your models here.

# 作者表
class AuthorModel(models.Model):
    name = models.CharField('作者名字',max_length=64)
    img = models.CharField('作者头像',max_length=256,default='http://rkm2dzt0t.bkt.clouddn.com/20221031215225.jpg')
    mobile = models.CharField('手机号',max_length=16)
    register_date = models.DateTimeField('注册时间', default=datetime.now())

    def __str__(self):
        return self.name

    class Meta:
        db_table = 'author'
        verbose_name = '作者表'


# 文章表
class ArticleModel(models.Model):
    article_name = models.CharField('文章名字',max_length=64)
    img = models.CharField('文章封面', max_length=256)
    author_id = models.ForeignKey(AuthorModel,on_delete=models.CASCADE,verbose_name='所属作者')
    issue_date = models.DateTimeField('发布时间',default=datetime.now())
    update_date = models.DateTimeField('更新时间', default=datetime.now())
    synopsis = models.TextField('文章内容', default='')

    def __str__(self):
        return self.article_name

    class Meta:
        db_table = 'article'
        verbose_name = '文章表'





















